<?php
include_once(dirname(dirname(__FILE__))."/common/config.inc.php");
header("content-type:text/html; charset=utf-8");
class ThePage
{
	var $smarty;
	var $userRequest;
	var $html_title="";
	var $mc;

	function ThePage()
	{
		global $error_object,$memcacheConfig;
		//检测动态码
		$this->smarty = Factory::getSmarty();
		$this->smarty->template_dir = TPL_PATH."id5/";
		$this->smarty->compile_dir = COM_PATH."main/";
		
		$this->userRequest = Factory::getBaseClass('UserRequest');
		$this->mc = Factory::getMemcached();
		
		//释放统计使用
		$this->smarty->assign('domain_name',DOMAIN_NAME);
		$this->smarty->assign('host_name',HOST_NAME);
		$this->smarty->assign("error_object",$error_object);
		$this->smarty->assign('css_path',CSS_PATH );
		$this->smarty->assign('js_path', JS_PATH);
		$this->smarty->assign('pic_path', PIC_PATH);
	}
	function set_title($title)
	{
		$this->smarty->assign("html_title",$this->html_title.$title);
	}
	function get_uuid()
	{
		while(1)
		{
			$uuid = get_uuid();
			if(!$this->mc->get(SFT.$uuid))
			{
				return $uuid;
			}
		}
	}
	
	function set_sub_info($icpcode)
	{
		global $coop_arr;
		$this->smarty->assign('logo',$coop_arr[$icpcode]['logo']);
		$this->smarty->assign('info',$coop_arr[$icpcode]['info']);
		
	}
}

function user_log($u_id,$log_info,$log_type="error",$action_type)
{
	$temp['user_log_id'] = "";
	$temp['user_id'] = $u_id;
	$temp['log_action'] = $_SERVER['REQUEST_URI'];
	$temp['action_referer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] :"";
	$temp['log_time'] = time();
	$temp['log_type'] = $log_type;
	$temp['ip_address'] = getUserIP();
	$temp['log_inof'] = $log_info;
	$temp['req_data'] = serialize($_REQUEST);
	//print_r($temp);exit();
	if(defined('USER_USE_LOG4J') && USER_USE_LOG4J)
	{
		unset($temp['user_log_id']);
		include_once(LOG4J_PATH."Logger.php");
		Logger::configure(USER_LOG4J_CONFIG);
		$logger = Logger::getLogger($action_type);
		$temp['log_inof'] = json_encode($temp['log_inof']);
		$log_msg = implode('#||#',$temp);
		$logger->debug($log_msg);
	}
}

//获取 icpcode 用户信息
function get_icpcode_info($icpcode)
{
	global $coop_arr;
	return isset($coop_arr[$icpcode]) ? $coop_arr[$icpcode] : array();
}


?>
